package com.lx.dao;

import com.lx.entity.Admin;
import com.lx.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AdminDao {

    //管理员登陆
    @Select("select * from admin where name=#{name} and password=#{password}")
    Admin adminLogin(@Param("name") String name,@Param("password") String password);

    //注册
    @Insert("insert into admin values(null,#{name},#{password})")
    boolean adminRegister(@Param("name") String name,@Param("password") String password);

    //查询账号是否存在
    @Select("SELECT * FROM admin WHERE name=#{name}")
    Admin getIsAdmin(String name);

    //修改密码
    @Update("UPDATE admin SET password = #{password} WHERE name=#{name}")
    boolean updateAdmin(Admin admin);

    //计算用户总数
    @Select("select * from user")
    List<User> countUser();

    //分页查询所有用户
    @Select("select * from user order by id desc limit #{n},#{m}")
    List<User> getUser(@Param("n") int n,@Param("m") int m);
}
